package com.zjj.lbw.designpattern.proxy.staticproxy;

import com.zjj.lbw.designpattern.proxy.Subject;

/**
 * @author zhanglei.zjj
 * @description 静态代理
 * @date 2023/7/13 23:26
 */
public class Proxy implements Subject {
    /**
     * 要代理的实现类
     */
    private Subject subject = null;

    /**
     * 默认代理自己
     */
    public Proxy() {
        this.subject = new Proxy();
    }

    public Proxy(Subject subject) {
        this.subject = subject;
    }

    /**
     * 实现接口方法
     */
    @Override
    public void request() {
        this.before();
        this.subject.request();
        this.after();
    }

    /**
     * 预处理
     */
    private void before() {
        System.out.println("静态代理前置增强逻辑.....");
    }

    /**
     * 后处理
     */
    private void after() {
        System.out.println("静态代理后置增强逻辑.....");
    }
}
